﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace Poll.PollWebPart
{
    [ToolboxItemAttribute(false)]
    public class PollWebPart : WebPart
    {
        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/Poll/PollWebPart/PollWebPartUserControl.ascx";

        [WebBrowsable(true),
        Personalizable(true),
        Category("Poll Parameters"),
        DisplayName("List Name"),
        WebDisplayName("List Name"),
        Description("Example: Polls"),
        DefaultValue("Polls")]
        public string ListPath { get; set; }

        protected override void CreateChildControls()
        {
            PollWebPartUserControl control = (PollWebPartUserControl)Page.LoadControl(_ascxPath);
            control.ListPath = ListPath;
            control.BackColor = "Gray";
            control.ForeColor = "Blue";
            Controls.Add(control);
        }
    }
}